********************************************************************************
*INES ANALYSIS WAVES 1-4
********************************************************************************

clear 
set more off


***PREPARING THE DATASET USING DATA DOWNLOADED FROM INES WEBSITE


use "data/1973-4.dta"

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*MERGE THE SURVEY DATASETS TOGETHER
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

***December 1973 wave 4

rename v1 id

keep id g2 g3 g37 g56 g12 g16 g19 g33 g34 g25 g44 g51 g55 g27 g58 g59 g62 g61 g63 g64 g66

rename g2 problem14
rename g3 problem24
rename g37 intendstovote4
rename g56 intendsparty4
rename g12 readsmore4
rename g16 radioads4
rename g19 tvads4
rename g33 respondentcaninfluence4
rename g34 electionscaninfluence4
rename g25 believeparties4
rename g44 importanttovote4
rename g51 likudsubstitute4
rename g55 vote694
rename g27 activeincampaign4
rename g58 partymember4
rename g59 sex4
rename g62 age4
rename g61 education4
rename g63 hhincome4
rename g64 religiosity4
rename g66 bornin4
gen interestedinpolitics4=.


gen leadersads4=.
gen countrysituation4=.



gen wave4=4

gen maarach694=.
replace maarach694=1 if vote694==4
replace maarach694=0 if vote694!=4 & vote694!=. & vote694!=0 & vote694!=14

gen likud694=.
replace likud694=1 if vote694==1 | vote694==2 | vote694==9
replace likud694=0 if vote694!=1 & vote694!=2 & vote694!=9 & vote694!=. & vote694!=0 & vote694!=14

gen didntvote694=.
replace didntvote694=1 if vote694==13
replace didntvote694=0 if vote694!=13 & vote694!=. & vote694!=0 & vote694!=14

gen indeplib694=.
replace indeplib694=1 if vote694==3
replace indeplib694=0 if vote694!=3 & vote694!=. & vote694!=0 & vote694!=14

gen religious694=.
replace religious694=1 if vote694==5 | vote694==6 | vote694==7
replace religious694=0 if vote694!=5 & vote694!=6 & vote694!=7 & vote694!=. & vote694!=0 & vote694!=14

gen left694=.
replace left694=1 if vote694==8 | vote694==10 | vote694==11
replace left694=0 if vote694!=8 & vote694!=10 & vote694!=11 & vote694!=. & vote694!=0 & vote694!=14

gen other694=.
replace other694=1 if vote694==12
replace other694=0 if vote694!=12 & vote694!=. & vote694!=0 & vote694!=14

gen unknown694=.
replace unknown694=0 if vote694>=1 & vote694<=13
replace unknown694=1 if vote694<=0 | vote694>13 | vote694==.

tab vote69, m

foreach var in maarach likud694 didntvote indeplib religious left other unknown{
tab `var', m
}

egen temp=rowtotal(maarach likud694 didntvote indeplib religious left other unknown)
tab temp, m
drop temp

sort id 
tempfile temp
save `temp'

clear

***November 1973 wave 3
use "data/1973-3.dta"

rename v1 id
sort id 

keep id f23 f2 f42 f43 f14 f50 f46 f49 f52 f54 f53 f55 f56 f58 

rename f23 leadersads3
rename f2 countrysituation3
rename f42 problem13
rename f43 problem23
rename f14 intendstovote3
rename f50 intendsparty3
rename f46 likudsubstitute3
rename f49 vote693
rename f52 sex3
rename f54 age3
rename f53 education3
rename f55 hhincome3
rename f56 religiosity3
rename f58 bornin3

gen wave3=3

gen readsmore3=.
gen radioads3=.
gen tvads3=.
gen respondentcaninfluence3=.
gen electionscaninfluence3=.
gen believeparties3=.
gen importanttovote3=.
gen activeincampaign3=.
gen partymember3=.
gen interestedinpolitics3=.

tab leadersads3, m

tab vote693, m

gen maarach693=.
replace maarach693=1 if vote693==4
replace maarach693=0 if vote693!=4 & vote693!=. & vote693!=0 & vote693!=14

gen likud693=.
replace likud693=1 if vote693==1 | vote693==2 | vote693==9
replace likud693=0 if vote693!=1 & vote693!=2 & vote693!=9 & vote693!=. & vote693!=0 & vote693!=14

gen didntvote693=.
replace didntvote693=1 if vote693==13
replace didntvote693=0 if vote693!=13 & vote693!=. & vote693!=0 & vote693!=14

gen indeplib693=.
replace indeplib693=1 if vote693==3
replace indeplib693=0 if vote693!=3 & vote693!=. & vote693!=0 & vote693!=14

gen religious693=.
replace religious693=1 if vote693==5 | vote693==6 | vote693==7
replace religious693=0 if vote693!=5 & vote693!=6 & vote693!=7 & vote693!=. & vote693!=0 & vote693!=14

gen left693=.
replace left693=1 if vote693==8 | vote693==10 | vote693==11
replace left693=0 if vote693!=8 & vote693!=10 & vote693!=11 & vote693!=. & vote693!=0 & vote693!=14

gen other693=.
replace other693=1 if vote693==12
replace other693=0 if vote693!=12 & vote693!=. & vote693!=0 & vote693!=14

gen unknown693=.
replace unknown693=0 if vote693>=1 & vote693<=13
replace unknown693=1 if vote693<=0 | vote693>13 | vote693==.

foreach var in maarach likud693 didntvote indeplib religious left other unknown{
tab `var', m
}

egen temp=rowtotal(maarach likud693 didntvote indeplib religious left other unknown)
tab temp, m
drop temp



merge 1:1 id using `temp'
drop if id==5265
drop _merge

sort id
tempfile temp
save `temp'

clear

***September 1973 wave 2
use "data/1973-2.dta"

rename v1 id
sort id 

keep id  c19 c51 c52 d45 e7 e8 c8 c13 c16 d8 d32 d10 d42 e16 e17 e19 

rename c19 leadersads2
rename c51 problem12
rename c52 problem22 
rename d45 intendstovote2
rename e7 intendsparty2
rename e8 vote692
rename c8 readsmore2
rename c13 radioads2
rename c16 tvads2
rename d8 believeparties2
rename d32 importanttovote2
rename d10 activeincampaign2
rename d42 partymember2
rename e16 sex2
rename e17 age2
rename e19 bornin2

gen wave2=2


gen countrysituation2=.
gen respondentcaninfluence2=.
gen electionscaninfluence2=.
gen likudsubstitute2=.
gen education2=.
gen hhincome2=.
gen religiosity2=.
gen interestedinpolitics2=.


tab vote692, m
tab intendsparty, m

gen maarach692=.
replace maarach692=1 if intendsparty==2 & vote692==1
replace maarach692=0 if intendsparty!=2 & vote692==1 & intendsparty!=. & intendsparty!=0 | intendsparty==2 & vote692!=1 & vote692!=0

gen likud692=.
replace likud692=1 if intendsparty==10 & vote692==1 | intendsparty==11 & vote692==1 |intendsparty==12 & vote692==1 | intendsparty==13 & vote692==1
replace likud692=0 if intendsparty!=10 & intendsparty!=11 & intendsparty!=12 & intendsparty!=13  & intendsparty!=. & intendsparty!=0 & vote69==1 | intendsparty==10 & vote69>1 & vote69!=. | intendsparty==11 & vote69>1 & vote69!=. | intendsparty==12 & vote69>1 & vote69!=. | intendsparty==13 & vote69>1 & vote69!=.

gen didntvote692=.
replace didntvote692=1 if vote692==3
replace didntvote692=0 if vote692!=3 & vote692!=. & vote692!=0 

gen indeplib692=.
replace indeplib692=1 if intendsparty==1 & vote692==1
replace indeplib692=0 if intendsparty!=1 & vote692==1 & intendsparty!=. & intendsparty!=0 | intendsparty==1 & vote692!=1 & vote692!=0  & vote69!=.

gen religious692=.
replace religious692=1 if intendsparty==3 & vote692==1 |intendsparty==4 & vote692==1 | intendsparty==5 & vote692==1
replace religious692=0 if intendsparty!=3 & intendsparty!=4 & intendsparty!=5 & vote69==1 & intendsparty!=. & intendsparty!=0 | intendsparty==3 & vote69>1 & vote69!=. | intendsparty==4 & vote69>1 & vote69!=. | intendsparty==5 & vote69>1 & vote69!=.

gen left692=.
replace left692=1 if intendsparty==6 & vote692==1 |intendsparty==7 & vote692==1 | intendsparty==8 & vote692==1 | intendsparty==9 & vote692==1
replace left692=0 if intendsparty!=6 & intendsparty!=7 & intendsparty!=8 & intendsparty!=9  & intendsparty!=.  & vote69==1 & intendsparty!=. & intendsparty!=0 | intendsparty==6 & vote69>1 & vote69!=. | intendsparty==7 & vote69>1 & vote69!=. | intendsparty==8 & vote69>1 & vote69!=. | intendsparty==9 & vote69>1 & vote69!=.

gen other692=.
replace other692=1 if intendsparty==14 & vote692==1
replace other692=0 if intendsparty!=14 & vote692==1 & intendsparty!=. & intendsparty!=0 | intendsparty==14 & vote692!=1 & vote692!=0 & vote692!=.

gen unknown692=.
replace unknown692=0 if intendsparty>=1 & vote692==1 & intendsparty!=. | vote692==3
replace unknown692=1 if intendsparty<=0 & vote692!=3 | vote692<=0 | vote692==. | vote692==2

foreach var in maarach likud692 didntvote indeplib religious left other unknown{
tab `var', m
}

egen temp=rowtotal(maarach likud692 didntvote indeplib religious left other unknown)
tab temp, m
drop temp

merge 1:1 id using `temp'
drop if id==5265
drop _merge

sort id
tempfile temp
save `temp'

clear

***May 1973 wave 1
use "data/1973-1.dta"

rename v1 id
sort id 
drop if id==5265 //dropping obs with the same id

keep id v3 v4 v27 v28 b12 b20 v66 v67 b7 b8 b21 b11 b23 b25 b26 b35 b37 b38 

rename v3 countrysituation1
rename v27 problem11
rename v28 problem21
rename b12 intendstovote1
rename b20 intendsparty1
rename v66 respondentcaninfluence1
rename v67 electionscaninfluence1
rename v4 interestedinpolitics1
rename b7 importanttovote1
rename b8 likudsubstitute1
rename b21 vote691
rename b11 partymember1
rename b23 sex1
rename b25 age1
rename b26 education1
rename b35 hhincome1
rename b37 religiosity1
rename b38 bornin1


gen wave1=1
gen leadersads1=.
gen readsmore1=.
gen radioads1=.
gen tvads1=.
gen believeparties1=.
gen activeincampaign1=.


tab vote691, m
tab intendsparty, m

gen maarach691=.
replace maarach691=1 if intendsparty==4 & vote691==1 | vote69==5
replace maarach691=0 if intendsparty!=4 & vote691==1 & intendsparty!=. & intendsparty!=0 & intendsparty!=13 & vote69==1 & maarach691!=1 
replace maarach691=0 if vote691!=5 & vote691!=0  & vote69!=. & maarach691!=1 

gen likud691=.
replace likud691=1 if intendsparty==1 & vote691==1 | intendsparty==2 & vote691==1 |intendsparty==11 & vote691==1 | vote691==2 | vote691==3 | vote691==12
replace likud691=0 if intendsparty!=1 & intendsparty!=2 & intendsparty!=11 & intendsparty!=. & intendsparty!=0 & intendsparty!=13 & vote69==1 & likud69!=1 
replace likud691=0 if vote69!=2 & vote!=3 & vote!=12 & vote69!=0 & vote69!=. & likud69!=1

gen didntvote691=.
replace didntvote691=1 if vote691==14
replace didntvote691=0 if vote691!=14 & vote691!=. & vote691!=0 & didntvote!=1

gen indeplib691=.
replace indeplib691=1 if intendsparty==3 & vote691==1 | vote69==4
replace indeplib691=0 if intendsparty!=3 & vote691==1 & intendsparty!=. & intendsparty!=0 & intendsparty!=13 & indeplib691!=1 
replace indeplib691=0 if vote691!=4 & vote691!=0  & vote69!=. & indeplib691!=1

gen religious691=.
replace religious691=1 if intendsparty==5 & vote691==1 |intendsparty==6 & vote691==1 | intendsparty==7 & vote691==1 | vote691>=6 & vote691<=8
replace religious691=0 if intendsparty!=5 & intendsparty!=6 & intendsparty!=7 & vote69==1 & intendsparty!=. & intendsparty!=0 & intendsparty!=13 & religious691!=1 
replace religious691=0 if vote69!=0 & vote69!=. & vote691!=6 & vote691!=7 & vote691!=8 & religious691!=1

gen left691=.
replace left691=1 if intendsparty==8 & vote691==1 |intendsparty==9 & vote691==1 | intendsparty==10 & vote691==1 | vote691>=9 & vote691<=11
replace left691=0 if intendsparty!=8 & intendsparty!=9 & intendsparty!=10 & intendsparty!=0  & intendsparty!=. & intendsparty!=13  & vote69==1 & left691!=1 
replace left691=0 if vote69!=9 & vote69!=10 & vote69!=11 & vote69!=0 & vote69!=. & left691!=1

gen other691=.
replace other691=1 if intendsparty==12 & vote691==1 | vote691==13
replace other691=0 if intendsparty!=12 & vote691==1 & intendsparty!=. & intendsparty!=0 & intendsparty!=13 & other!=1 
replace other691=0 if vote691!=13 & vote69!=0 & vote69!=. & other!=1

gen unknown691=0
replace unknown691=1 if maarach691==. & likud69==. & didnt==. & indeplib==. & religious==. & left==. & other==.
replace unknown691=1 if maarach691==0 & likud69==0 & didnt==0 & indeplib==0 & religious==0 & left==0 & other==0


foreach var in maarach likud691 didntvote indeplib religious left other unknown{
tab `var', m
}

egen temp=rowtotal(maarach likud691 didntvote indeplib religious left other unknown)
tab temp, m
list id maarach likud691 didntvote indeplib religious left other unknown if temp>1
drop temp


merge 1:1 id using `temp'
drop if id==5265
drop _merge

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*RESHAPE WIDE INTO LONG
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

reshape long wave countrysituation problem1 problem2 respondentcaninfluence electionscaninfluence importanttovote interestedinpolitics likudsubstitute partymember intendstovote intendsparty vote69 maarach69 likud69 didntvote69 indeplib69 religious69 left69 other69 unknown69 sex age education hhincome religiosity bornin leadersads readsmore radioads tvads believeparties activeincampaign, i(id) j(survey)

*Dropping waves in which respondents did not participate
drop if wave==.

*label drop _all
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*RECODE VARIABLES FOR ANALYSIS
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*Country's situation today compared to 4 years ago (compared to pre-war)
replace countrysituation=. if countrysituation==0

*~~~~~~~~~~~~~~
*Which leaders wants to see in campaign ads: dummies for Golda, Begin, Dayan
gen ad_golda=.
replace ad_golda=1 if leadersads==1 & survey==3
replace ad_golda=1 if leadersads==1 & survey==2
replace ad_golda=0 if leadersads!=1 & leadersads!=0 & survey==2 | leadersads!=1 & leadersads!=.  & survey==3 
bys wave: tab ad_golda, m

gen ad_begin=.
replace ad_begin=1 if leadersads==6 & survey==3
replace ad_begin=1 if leadersads==3 & survey==2
replace ad_begin=0 if leadersads!=3 & leadersads!=0 & survey==2 | leadersads!=6  & leadersads!=. & survey==3 
bys wave: tab ad_begin, m

gen ad_dayan=.
replace ad_dayan=1 if leadersads==2 & survey==3
replace ad_dayan=1 if leadersads==2 & survey==2
replace ad_dayan=0 if leadersads!=2 & leadersads!=0 & survey==2 | leadersads!=2  & leadersads!=. & survey==3 
bys wave: tab ad_dayan, m

la var ad_golda "Wants to see Golda Meir in campaign ads"
la var ad_begin "Wants to see Menachem Begin in campaign ads"
la var ad_dayan "Wants to see Moshe Dayan in campaign ads"

*~~~~~~~~~~~~~~
*Country's situation
gen situationbetter=.
replace situationbetter=1 if countrysituation==1 & survey==1 | countrysituation==1 & survey==3 | countrysituation==2 & survey==3 
replace situationbetter=0 if  countrysituation>1 & survey==1 | countrysituation==2 & survey==3 

gen situationworse=.
replace situationworse=1 if countrysituation==3 & survey==1 | countrysituation==4 & survey==3 | countrysituation==5 & survey==3 
replace situationworse=0 if  countrysituation<3 & survey==1 | countrysituation<4 & survey==3 

tab situationbetter, m

tab situationworse, m

*~~~~~~~~~~~~~~
*Important problems

gen problemsecurity=.
replace problemsecurity=1 if problem1==1 | problem2==1
replace problemsecurity=0 if problem1!=1 & problem1!=0 & problem1!=. & problem1!=9 & problem2!=1 & problem2!=0 & problem2!=. & problem2!=9
gen problempeace=.
replace problempeace=1 if problem1==2 | problem2==2
replace problempeace=0 if problem1!=2 & problem1!=0 & problem1!=. & problem1!=9 | problem2!=2 & problem2!=0 & problem2!=. & problem2!=9
gen problemeconomy=.
replace problemeconomy=1 if problem1==3 | problem2==3
replace problemeconomy=0 if problem1!=3 & problem1!=0 & problem1!=. & problem1!=9 | problem2!=3 & problem2!=0 & problem2!=. & problem2!=9
gen problemsocial=.
replace problemsocial=1 if problem1==4 | problem1==5 | problem1==6 | problem2==4 | problem2==5 | problem2==6
replace problemsocial=0 if problem1!=4 & problem1!=5 & problem1!=6 & problem1!=0 & problem1!=. & problem1!=9 | problem2!=4 & problem2!=5 & problem2!=6 & problem2!=0 & problem2!=. & problem2!=9
la var problemsecurity "1 if respondent named security as one of the two most important problems, 0 if not"
la var problempeace "1 if respondent named peace as one of the two most important problems, 0 if not"
la var problemeconomy "1 if respondent named economy as one of the two most important problems, 0 if not"
la var problemsocial "1 if respondent named social issues as one of the two most important problems, 0 if not"


*~~~~~~~~~~~~~~
*Intends to vote - binary
gen voteintention=.
replace voteintention=. if intendstovote==0
replace voteintention=1 if intendstovote==1 & wave==1 | intendstovote==1 & wave>1 | intendstovote==2 & wave>1
replace voteintention=0 if intendstovote==2 & wave==1 | intendstovote==3 & wave>1 | intendstovote==4 & wave>1
tab voteintention, m
tab intendstovote, m
gen intendstovote_binary=voteintention
drop voteintention
la var intendstovote_binary "1 if respondent intends to vote in upcoming election, 0 if not"

*Non-binary, excluding wave 1
gen voteintention=.
replace voteintention=. if intendstovote==0
replace voteintention=1 if intendstovote==4 & wave>1
replace voteintention=2 if intendstovote==3 & wave>1 
replace voteintention=3 if intendstovote==2 & wave>1 
replace voteintention=4 if intendstovote==1 & wave>1 
tab voteintention, m
tab intendstovote, m
gen intendstovote_ordinal=voteintention
drop voteintention
la var intendstovote_ordinal "1=centainly not; 2=i don't think so; 3=i think so; 4=certainly yes"





*~~~~~~~~~~~~~~
*Which party will vote for

gen votemaarach=.
replace votemaarach=1 if intendsparty==4 & survey==1 | intendsparty==2 & survey==2 | intendsparty==3 & survey==3 | intendsparty==3 & survey==4
replace votemaarach=0 if intendsparty!=4 & intendsparty!=0 & intendsparty!=13 & survey==1
replace votemaarach=0 if intendsparty!=2 & intendsparty!=0 & survey==2
replace votemaarach=0 if intendsparty!=3 & intendsparty!=0 &  intendsparty!=50 & intendsparty!=12  & survey==3 
replace votemaarach=0 if intendsparty!=3 & intendsparty!=0  & survey==4
la var votemaarach "1 if respondent intends to vote for Maarach, 0 if not, missing answers excl."
gen votelikud=.
replace votelikud=1 if intendsparty==1 & survey==1 | intendsparty==2 & survey==1 | intendsparty==11 & survey==1 | intendsparty==12 & survey==2 |  intendsparty==13 & survey==2 |  intendsparty==11 & survey==2 |  intendsparty==10 & survey==2 |  intendsparty==1 & survey==3 |  intendsparty==1 & survey==4
replace votelikud=0 if intendsparty!=1 & intendsparty!=2 &  intendsparty!=11  & intendsparty!=0 & intendsparty!=13 & survey==1 
replace votelikud=0 if intendsparty!=12 & intendsparty!=13 & intendsparty!=11 & intendsparty!=10 & intendsparty!=0 & survey==2
replace votelikud=0 if intendsparty!=1 & intendsparty!=0 & intendsparty!=50 & survey==3
replace votelikud=0 if intendsparty!=1 & intendsparty!=0 &  survey==4
la var votelikud "1 if respondent intends to vote for Likud, 0 if not, missing answers excl."


*~~~~~~~~~~~~~~
*Believes to what parties are saying in campaign (71% missing values)
replace believeparties=. if believeparties==0 | believeparties==6
gen temp=5-believeparties if believeparties!=.
tab believeparties, m
tab temp, m
replace believeparties=temp
drop temp
*rescale from 0 to 1 instead of from 1 to 4
replace believeparties=(believeparties-1)/3
la var believeparties "To what extent respondent believes what parties say during campaign, from 0 to 1"

*~~~~~~~~~~~~~~
*Important to vote
replace importanttovote=. if importanttovote==0 | importanttovote==6
gen temp=5-importanttovote if importanttovote!=.
tab importanttovote, m
tab temp, m
replace importanttovote=temp
drop temp
*rescale from 0 to 1 instead of from 1 to 4
replace importanttovote=(importanttovote-1)/3
la var importanttovote "To what extend it is personally important for the respondent to vote, 0 to 1"


*~~~~~~~~~~~~~~
*Important to vote
replace intendstovote=. if intendstovote==0 | intendstovote==5 | intendstovote==6
gen temp=4-intendstovote if intendstovote!=.
tab intendstovote, m
tab temp, m
replace intendstovote=temp
drop temp
*rescale from 0 to 1 instead of from 1 to 4
replace intendstovote=(intendstovote)/3
la var intendstovote "To what extend does respondent intend to vote, 0 to 1"


*~~~~~~~~~~~~~~
*Likud can substitute government

*Copy to wave 2 from wave 1
foreach var in likudsubstitute{
gen t`var'1=`var' if survey==1
bys id: egen t`var'2=max(t`var'1)
replace `var'=t`var'2 if `var'==. & survey==2 & t`var'2!=. & wave==2
drop t`var'1 t`var'2
}

replace likudsubstitute=. if likudsubstitute==0 | likudsubstitute==7
gen temp=5-likudsubstitute if likudsubstitute!=.
tab likudsubstitute, m
tab temp, m
replace likudsubstitute=temp
drop temp
*rescale from 0 to 1 instead of from 1 to 4
replace likudsubstitute=(likudsubstitute-1)/3
la var likudsubstitute "To what extend can Likud substitute the government, from 0 to 1"

*~~~~~~~~~~~~~~
*Wave 2 demographics copied from wave 1 because it is a panel
foreach var in hhincome education religiosity vote69 interestedinpolitics electionscaninfluence{
gen t`var'1=`var' if survey==1
bys id: egen t`var'2=max(t`var'1)
replace `var'=t`var'2 if `var'==. & survey==2 & t`var'2!=. & wave==2
drop t`var'1 t`var'2
}


*~~~~~~~~~~~~~~
*Elections can influence policy
replace electionscan=. if electionscan==0
*reverse scale
replace electionscan=5-electionscan

*~~~~~~~~~~~~~~
*Respondent can influence policy
tab respondentcan, m
replace respondentcan=. if respondentcan==0 | respondentcan==6
*reverse scale
*replace respondentcan=5-respondentcan
*tab respondentcan, m

*~~~~~~~~~~~~~~
*Ads on radio and TV
replace radioads=. if radioads==0
replace tvads=. if tvads==0
gen temp=.
replace temp=0 if radioads==2 & survey==2
replace temp=1 if radioads==1 & survey==2
replace temp=1 if radioads==1 & survey==4 | radioads==2 & survey==4
replace temp=0 if radioads==3 & survey==4 | radioads==4 & survey==4
gen temp2=.
replace temp2=0 if tvads==2 & survey==2
replace temp2=1 if tvads==1 & survey==2
replace temp2=1 if tvads==1 & survey==4 | tvads==2 & survey==4
replace temp2=0 if tvads==3 & survey==4 | tvads==4 & survey==4
tab radioads, m
tab tvads, m
tab temp if survey==2 | survey==4, m
tab temp2  if survey==2 | survey==4, m

replace radioads=temp
replace tvads=temp2

drop temp temp2

*Generating alpha variable

alpha radioads tvads, item gen(adsexposure)
sum adsexposure, de



*~~~~~~~~~~~~~~
*Female
gen female=.
replace female=1 if sex==2
replace female=0 if sex==1
la var female "1 if respondent is female, 0 if respondent is male"
la def female 1"Female" 0"Male"
la val female female

*~~~~~~~~~~~~~~
*Age
replace age=. if age==0
gen temp=.
replace temp=1 if age==1 | age==2
replace temp=2 if age==3 | age==4
replace temp=3 if age==5 | age==6
replace temp=4 if age==7 | age==8
replace temp=5 if age==9

replace age=temp
drop temp
la def age 1"Age 20-29" 2"Age 30-39" 3"Age 40-49" 4"Age 50-64" 5"Age 65+"
la val age age
la var age "Age group"
tab age

*~~~~~~~~~~~~~~
*Education
replace education=. if education==0
gen temp=.
replace temp=1 if education>=1 & education<=3
replace temp=2 if education>3 & education<=6
replace temp=3 if education==7
replace temp=4 if education==8
replace education=temp
drop temp
la def education 1"0-8 yrs of education" 2"9-12 yrs of schooling" 3"+12yrs, but less than college" 4"College degree"  
la val education education
la var education "Education"
tab education, m

*~~~~~~~~~~~~~~
*Income
gen temp=.
replace temp=1 if hhincome>=1 & hhincome<=3 & survey<3 | hhincome==1 & survey>=3
replace temp=2 if hhincome==4 & survey<3 | hhincome==2 & survey>=3
replace temp=3 if hhincome==5 & survey<3 | hhincome==3 & survey>=3
replace temp=4 if hhincome==6 & survey<3 | hhincome==4 & survey>=3
replace temp=5 if hhincome==7 & survey<3 | hhincome==5 & survey>=3
replace temp=6 if hhincome==8 & survey<3 | hhincome==6 & survey>=3
replace temp=7 if hhincome==9 & survey<3 | hhincome>=7 & hhincome!=. & survey>=3

tab hhincome, m
tab temp, m

replace hhincome=temp
drop temp
la def hhincome 1"Income 0-599" 2"Income 600-799" 3"Income 800-999" 4"Income 1,000-1,249" 5"Income 1,250-1,499" 6"Income 1,500-1,749" 7"Income 1,750+"
la val hhincome hhincome


*~~~~~~~~~~~~~~
*Religiosity
replace religiosity=. if religiosity==0
la def religiosity 1"Observes thoroughly" 2"Observes to a great extent" 3"Observes to a small extent" 4"Does not observe at all"
la val religiosity religiosity

*~~~~~~~~~~~~~~
*Origin dummies
gen borninisrael=.
replace borninisrael=1 if bornin==1 | bornin==2 | bornin==3
replace borninisrael=0 if bornin==4 | bornin==5 | bornin==6
gen originasiaafrica=.
replace originasiaafrica=1 if bornin==2 | bornin==4
replace originasiaafrica=0 if bornin==1 | bornin==3 | bornin==5 | bornin==6
la var borninisrael "1 if respondent born in israel; 0 if born outside israel"
la var originasiaafrica "1 if respondent or their father born in Asia/Africa; 0 if not"
la def borninisrael 1"Born in Israel" 0"Born not in Israel"
la val borninisrael borninisrael
la def originasiaafrica 1"Origin in Asia or Africa" 0"Origin not in Asia and not in Africa"
la val originasiaafrica originasiaafrica

*~~~~~~~~~~~~~~
*Party member indicator
replace partymember=. if partymember==0
gen temp=.
replace temp=1 if partymember==1 | partymember==2 | partymember==3
replace temp=0 if partymember==4 | partymember==5
replace partymember=temp
drop temp
la def partymember 1 "Party member" 0 "Party non-member"
la val partymember partymember

*~~~~~~~~~~~~~~
*Postwar survey indicator
gen postwar=0
replace postwar=1 if survey==3 | survey==4
la var postwar "1 if post-war survey, 0 if pre-war survey"
la def postwar 1"Post-war" 0"Pre-war"
la val postwar postwar

gen postwar2=.
replace postwar2=1 if survey==3 
replace postwar2=0 if survey==2 
la var postwar2 "1 if post-war survey, 0 if pre-war survey"
la def postwar2 1"Post-war" 0"Pre-war"
la val postwar2 postwar2


gen post_placebo=.
replace post_placebo=1 if survey==4
replace post_placebo=0 if survey==3
la var post_placebo "Placebo (Post)"

gen pre_placebo=.
replace pre_placebo=1 if survey==2
replace pre_placebo=0 if survey==1
la var pre_placebo "Placebo (Pre)"


***ANALYSIS -- TABLES A1-A9



ssc install sutex


****TABLE A1
bys postwar: sutex female age religiosity hhincome education borninisrael originasiaafrica



****Models

*controls
gl demog_controls i.female i.age i.religiosity i.hhincome i.education i.borninisrael i.originasiaafrica  
gl political_controls maarach69 likud69 didntvote69 indeplib69 religious69 left69 other69



****TABLE A2: EFFECTS OF WAR ON SUPPORT FOR LEADERS AND PARTIES

* Leaders

reg ad_golda postwar $demog_controls $political_controls if survey==2 | survey==3

reg ad_dayan postwar $demog_controls $political_controls if survey==2 | survey==3

reg ad_begin postwar $demog_controls $political_controls if survey==2 | survey==3


* Parties


reg votemaarach postwar $demog_controls i.survey

reg votelikud postwar $demog_controls i.survey



****TABLE A3: MAIN RESULTS-ROBUSTNESS TO PROBIT SPECIFICATION

* Leaders

probit ad_golda postwar $demog_controls  if survey==2 | survey==3
estimates store golda_prob, title(Prime Minister)


probit ad_dayan postwar $demog_controls if survey==2 | survey==3
estimates store dayan_prob, title(Min. of Defense)


probit ad_begin postwar $demog_controls if survey==2 | survey==3
estimates store begin_prob, title(Opposition leader)

* Parties


reg votemaarach postwar $demog_controls i.survey
estimates store labor_prob, title(Vote Alignment)

reg votelikud postwar $demog_controls i.survey
estimates store likud_prob, title(Vote Likud)

****TABLE A4: MAIN RESULTS-OMITTING SELF-REPORTED 1969 VOTE

* Leaders
reg ad_golda postwar $demog_controls if survey==2 | survey==3
estimates store golda_ols_pol, title(Prime Minister)

reg ad_dayan postwar $demog_controls if survey==2 | survey==3
estimates store dayan_ols_pol, title(Min. of Defense)

reg ad_begin postwar $demog_controls if survey==2 | survey==3
estimates store begin_ols_pol, title(Opposition leader)

* Parties

reg votemaarach postwar $demog_controls i.survey
estimates store labor_ols_pol, title(Vote Alignment)

reg votelikud postwar $demog_controls i.survey
estimates store likud_ols_pol, title(Vote Likud)

****TABLES A5 and A7: Matching on covariates -- correcting imbalance

probit ad_golda postwar $demog_controls 
teffects nnmatch (ad_golda  female age religiosity hhincome education borninisrael originasiaafrica) (postwar),  biasadj(age hhincome education)  atet
tebalance summarize

probit ad_dayan postwar $demog_controls
teffects nnmatch (ad_dayan  female age religiosity hhincome education borninisrael originasiaafrica) (postwar),  biasadj(age hhincome education) atet
tebalance summarize

probit ad_begin postwar $demog_controls
teffects nnmatch (ad_begin  female age religiosity hhincome education borninisrael originasiaafrica) (postwar),  biasadj(age hhincome education) atet
tebalance summarize

****TABLES A6 and A7: Matching on covariates -- correcting imbalance


probit votemaarach postwar $demog_controls 
teffects nnmatch (votemaarach  female age religiosity hhincome education borninisrael originasiaafrica) (postwar),  biasadj(age hhincome education)  atet
tebalance summarize


probit votelikud postwar $demog_controls
teffects nnmatch (votelikud  female age religiosity hhincome education borninisrael originasiaafrica) (postwar),  biasadj(age hhincome education)  atet
tebalance summarize


****TABLE A8: Placebo test 

probit votemaarach pre_placebo $demog_controls $political_controls if survey <3

probit votelikud pre_placebo $demog_controls $political_controls if survey <3

probit votemaarach post_placebo $demog_controls $political_controls if survey >2

probit votelikud post_placebo $demog_controls $political_controls  if survey >2


****TABLE A9: War effects on turnout

* Intention to Vote

oprobit intendstovote postwar $demog_controls  

reg intendstovote postwar $demog_controls 

reg intendstovote postwar $demog_controls $political_controls if wave != 1 & wave !=4

oprobit importanttovote postwar $demog_controls   if wave!=2 &  unknown==0

reg importanttovote postwar $demog_controls  


********************************************************************************
*INES ANALYSIS WAVE 5 - MECHANISM
********************************************************************************


*TABLE 1 - DETERMINANTS OF VOTE CHANGE IN 1973 



clear
* load data
use "data/1973-5.dta"



*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Keep specific variable and rename them
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*** Wave 5

rename v1 id

keep id h3 h4 h5 h6 h7 h8 h9 h10 h12 h13 h14 h15 h16 h17 h18 h27 h29 h32 h26 h54 h53 h57 h58 h59 h60 h61 h62 h63 h64 h65 h66

rename h3 emet_fail_econ
rename h4 likud_not_giveup
rename h5 emet_notrust
rename h6 emet_fault_war
rename h7 likud_geneva_strong
rename h8 emet_no_fp
rename h9 likud_leader_qual
rename h10 likud_unity_gov
rename h12 emet_experience
rename h13 emet_least_evil
rename h14 emet_peace
rename h15 emet_extreme
rename h16 emet_ses
rename h17 emet_leader_qual
rename h18 fear_change
rename h26 same_party
rename h27 yk_change_vote
rename h29 when_vote_decision
rename h32 why_vote
rename h54 vote_post_war
rename h53 vote_1969
rename h57 sex
rename h58 reserve
rename h59 schooling
rename h60 age
rename h61 income
rename h62 relig
rename h63 occupation
rename h65 location
rename h64 father_place_birth
rename h66 survey_date



* recode rationalizations for voting as dummies 

foreach v of varlist emet_fail_econ-fear_change {
replace `v' = 1 if `v' == 1
replace `v' = 1 if `v' == 2
replace `v' = 1 if `v' == 3
replace `v' = 0 if `v' != 1
  }


* recode outcomes
gen change_since_1969 = 0
replace change_since_1969 = 1 if same_party == 2
gen change_yk = 0
replace change_yk = 1 if yk_change_vote == 1
gen change_at_war =0
replace change_at_war = 1 if when_vote_decision == 2


* Prepare covariates

*controls
gl dummies emet_fault_war emet_fail_econ likud_not_giveup emet_notrust likud_geneva_strong emet_no_fp likud_leader_qual likud_unity_gov emet_experience emet_least_evil emet_peace emet_extreme emet_ses emet_leader_qual fear_change
gl controls sex i.schooling i.age i.income i.relig i.location i.father_place_birth


*TABLE 1 - Determinants of vote change in 1973

reg change_since_1969 $dummies $controls

reg change_yk $dummies $controls

reg change_at_war $dummies $controls

